package com.example.anew.journey.mynewjourney.base;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

import com.example.anew.journey.mynewjourney.utils.TypefaceUtil;
import com.mob.MobSDK;
import com.taobao.sophix.SophixManager;
import com.umeng.commonsdk.UMConfigure;



/**
 * 杭州惟君医疗科技有限公司15
 * Created by 20433 on 2018/3/2
 */

public class MyApplication extends Application {
    public static Context getMcontext() {
        return mcontext;
    }

    private static Context mcontext;
    private static Handler mHandler;

    public static Handler getmHandler() {
        return mHandler;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mcontext = getApplicationContext();
        mHandler = new Handler();

        // todo 热修复主动拉取补丁
        // queryAndLoadNewPatch不可放在attachBaseContext 中，否则无网络权限，建议放在后面任意时刻，如onCreate中
        SophixManager.getInstance().queryAndLoadNewPatch();

        initSDK();
        initOnther();
    }
    private void initOnther() {
        TypefaceUtil.replaceSystemDefaultFont(this,"fonts/RobotoSlab-Regular.ttf");
    }

    private void initSDK() {
        // 通过代码注册你的AppKey和AppSecret
        MobSDK.init(getMcontext(), "2493ec47bafbf", "49d077554cba02d09d2396e8b4382ccf");
        UMConfigure.init(this, null, null, UMConfigure.DEVICE_TYPE_PHONE, null);
    }

}
